package cate.game.play.buff.h;

import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.buff.Buff;
import cate.game.play.buff.BuffHandler;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;

/**
 * 携带该状态的目标下回合会吸收发起者1个负面状态,并将其附加给随机1个友方单位
 */
public class 暗星BH extends BuffHandler {


	@Override
	public void onRoundBegin(ActionCtx action) {
		Buff badBuff = buff.caster.buff.findOne(b -> !b.isGood() && b.cfg.dispelAble());
		if (badBuff != null) {
			badBuff.markInvalid(action);
			Fighter one = TargetSelector.findOne(buff.owner, action.getTeamVs(), new TargetFilterParam().scopeSet(GDSkill.Scope.FRIENDS));
			if (one != null) {
				one.buff.tryAddByTid(action, buff.owner, badBuff.tid);
			}
		}
	}
}
